import { S } from '../../s';
import { IPSAppDELogic } from '../../app/dataentity/ipsapp-delogic';
import { IPSAppDEMethod } from '../../app/dataentity/ipsapp-demethod';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSControlAction } from '../ipscontrol-action';
import { IPSAjaxControlHandlerAction } from './ipsajax-control-handler-action';
import { IPSDEOPPriv } from '../../dataentity/priv/ipsdeoppriv';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAjaxControlHandlerActionImpl
  extends PSModelObjectImpl
  implements IPSAjaxControlHandlerAction, IPSControlAction
{
  protected adpsappdelogic: IPSAppDELogic;
  getADPSAppDELogic(): IPSAppDELogic | null {
    if (this.adpsappdelogic != null) return this.adpsappdelogic;
    const value = this.M.getADPSAppDELogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.adpsappdelogic = ipsappdataentity.findPSAppDELogic(value);
    }
    return this.adpsappdelogic;
  }

  get actionDesc(): string {
    return this.M.actionDesc;
  }

  get actionName(): string {
    return this.M.actionName;
  }

  get actionType(): string {
    return this.M.actionType;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  get dataAccessAction(): string {
    return this.M.dataAccessAction;
  }

  protected psappdemethod: IPSAppDEMethod;
  getPSAppDEMethod(): IPSAppDEMethod | null {
    if (this.psappdemethod != null) return this.psappdemethod;
    const value = this.M.getPSAppDEMethod;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdemethod = ipsappdataentity.findPSAppDEMethod(value);
    }
    return this.psappdemethod;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psdeoppriv: IPSDEOPPriv;
  getPSDEOPPriv(): IPSDEOPPriv | null {
    return (
      this.psdeoppriv ||
      (this.psdeoppriv = this.fillObjectModel(
        S._270,
        this.M.getPSDEOPPriv,
        S._2a6,
      ) as IPSDEOPPriv)
    );
  }

  get timeout(): number {
    return this.M.timeout != null ? this.M.timeout : -1;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }
  get cls(): string {
    return 'PSAjaxControlHandlerActionImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._92 || cls == S._93 || cls == S._94) return true;
    return super.instanceof(cls);
  }
}
